export default {
  //  海康
  LoadCamera() {
    cameraObj = parent.vm.camera;
    // 检查插件是否已经安装过
    if (WebVideoCtrl.I_CheckPluginInstall()!=0) {
      openWarningMsg("您还未安装过插件，双击开发包目录里的WebComponents.exe安装！");
      return;
    }

    // 初始化插件参数及插入插件
    WebVideoCtrl.I_InsertOBJECTPlugin("video");
    // 检查插件是否最新
    if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {
      openWarningMsg("检测到新的插件版本，双击开发包目录里的WebComponents.exe升级！");
      return;
    }
    this.camaralogin();
  },
  camaralogin() {//摄像头登录
    var iRet = WebVideoCtrl.I_Login(cameraObj.CameraIp, 1, cameraObj.ControlPort, cameraObj.UserName, cameraObj.Password, {
      success: function () {
        //子码流播放
        vm.clickStartRealPlay(2);
      },
      error: function () {
        openErrorMsg("登录失败!");
      }
    });
  },
  cameraLogout() {
    WebVideoCtrl.I_Stop();
    var res = WebVideoCtrl.I_Logout(cameraObj.CameraIp);
  },
  clickStartRealPlay(streamType) {
    var oWndInfo = WebVideoCtrl.I_GetWindowStatus(0);
    // 已经在播放了，先停止
    if (oWndInfo != null) {
      WebVideoCtrl.I_Stop();
    }
    var iRet = WebVideoCtrl.I_StartRealPlay(cameraObj.CameraIp, {
      iStreamType: streamType
    });
  }
}
